/***************************************************************************
 *   Copyright (c) YEAR YOUR NAME         <Your e-mail address>            *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                       *
 ***************************************************************************/


#include "PreCompiled.h"
#ifndef _PreComp_
#endif


#include <Base/Console.h>
#include <Base/Exception.h>

#include "DFCalculator.h"
#include "ddapostplayer.h"
#include "BaseConfigs.h"

static PyObject* DDAGui_setCurrentProjectPath(PyObject * /*self*/, PyObject *args)
{
    char* path;
    if(!PyArg_ParseTuple(args , "s" , &path))
        return NULL;

    strcpy(DDAGui::currentProjectPath , path);
    printf("get project path : %s\n" , DDAGui::currentProjectPath);
    return (PyObject*)Py_BuildValue("i" , 1);
}
extern void clearPostPlayer();
static PyObject* DDAGui_clearPlayer(PyObject * /*self*/, PyObject *args)
{
    clearPostPlayer();
    printf("DG Player cleared\n");
    return (PyObject*)Py_BuildValue("i" , 1);
}

extern void clearCalculator();
static PyObject* DDAGui_clearCalculator(PyObject * /*self*/, PyObject *args)
{
    clearCalculator();
    printf("DF Calculator cleared\n");
    return (PyObject*)Py_BuildValue("i" , 1);
}

extern void startDFCalc();
static PyObject* DDAGui_startDFCalculator(PyObject * /*self*/, PyObject *args)
{
    startDFCalc();
    printf("DF Calculator started\n");
    return (PyObject*)Py_BuildValue("i" , 1);
}

extern void setCalculatorRealTime(int flag);
static PyObject* DDAGui_setDFCalculatorRealTime(PyObject * /*self*/, PyObject *args)
{
    int flag;
    if(!PyArg_ParseTuple(args , "i" , &flag))
        return NULL;
    
    setCalculatorRealTime(flag);
    printf("DF Calculator real time : %d\n", flag);
    return (PyObject*)Py_BuildValue("i" , 1);
}

extern void setInterval4Calculation(int interval);
static PyObject* DDAGui_setInterval4Calculation(PyObject * /*self*/, PyObject *args)
{
	int flag;
	if(!PyArg_ParseTuple(args , "i" , &flag))
		return NULL;

	setInterval4Calculation(flag);
	printf("DF Calculator set frames mod : %d\n", flag);
	return (PyObject*)Py_BuildValue("i" , 1);
}

extern void setScale4Display(int interval);
static PyObject* DDAGui_setScale4Display(PyObject * /*self*/, PyObject *args)
{
	int flag;
	if(!PyArg_ParseTuple(args , "f" , &flag))
		return NULL;

	setScale4Display(flag);
	printf("DF Calculator set scale : %d\n", flag);
	return (PyObject*)Py_BuildValue("i" , 1);
}


/* registration table  */
struct PyMethodDef DDAGui_methods[] = {
    {"setCurrentProjectPath",DDAGui_setCurrentProjectPath,METH_VARARGS,
            "setCurrentProjectPath() -- set current project path\n"},
    {"clearPlayer",DDAGui_clearPlayer,METH_VARARGS,
    "clearPlayer() -- clear DG player.\n"},
    {"clearCalculator",DDAGui_clearCalculator,METH_VARARGS,
    "clearCalculator() -- clear DF calculator.\n"},
    {"startCalculator",DDAGui_startDFCalculator,METH_VARARGS,
    "startCalculator() -- start DF calculator.\n"},
    {"setDFCalculatorRealTime",DDAGui_setDFCalculatorRealTime,METH_VARARGS,
    "setDFCalculatorRealTime() -- start DF calculator.\n"},
	{"setInterval4Calculation",DDAGui_setInterval4Calculation,METH_VARARGS,
	"setDFCalculatorRealTime() -- start DF calculator.\n"},
    {NULL, NULL}                   /* end of table marker */
};
